package com.aggron.concurrency.threadpool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author LR2SD
 * @description ScheduledThreadPool测试类
 * @date 2018-06-14 21:26
 */
@Slf4j
public class ThreadPoolExample4 {
    public static void main(String [] args){
        ScheduledExecutorService executorService= Executors.newScheduledThreadPool(5);
        executorService.schedule(new Runnable() {
            @Override
            public void run() {
                log.warn("schedule");
            }
        },100, TimeUnit.MILLISECONDS);

        executorService.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                log.warn("schedule scheduleAtFixedRate");
            }
        },1,3,TimeUnit.SECONDS);
    }
}
